#!/bin/bash

echo "========================================"
echo "Flutter Flavor 证书生成脚本"
echo "========================================"
echo

echo "正在创建keystore目录..."
mkdir -p android/keystore

echo
echo "生成开发环境证书..."
keytool -genkey -v -keystore android/keystore/dev_keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias flutterdome_dev -storepass dev123456 -keypass dev123456 -dname "CN=FlutterDome Dev, OU=Development, O=YourCompany, L=City, S=State, C=CN"

echo
echo "生成测试环境证书..."
keytool -genkey -v -keystore android/keystore/staging_keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias flutterdome_staging -storepass staging123456 -keypass staging123456 -dname "CN=FlutterDome Staging, OU=Staging, O=YourCompany, L=City, S=State, C=CN"

echo
echo "生成生产环境证书..."
keytool -genkey -v -keystore android/keystore/prod_keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias flutterdome_prod -storepass prod123456 -keypass prod123456 -dname "CN=FlutterDome Prod, OU=Production, O=YourCompany, L=City, S=State, C=CN"

echo
echo "========================================"
echo "证书生成完成！"
echo "========================================"
echo
echo "生成的证书文件："
echo "- android/keystore/dev_keystore.jks"
echo "- android/keystore/staging_keystore.jks"
echo "- android/keystore/prod_keystore.jks"
echo
echo "证书信息："
echo "Dev:     别名=flutterdome_dev,     密码=dev123456"
echo "Staging: 别名=flutterdome_staging, 密码=staging123456"
echo "Prod:    别名=flutterdome_prod,    密码=prod123456"
echo
echo "请妥善保管这些证书文件和密码！"
echo
